﻿@{
    ViewBag.Title = "Home Page";
}
@using Model

<link href="~/Content/tableStyle.css" rel="stylesheet" />
<script src="~/Scripts/jquery-3.4.1.js"></script>
<script>
    //$(function () {
    //    $(".createContract").click(function () {
    //        applyGenerate($(this).attr("ids"));
    //    });
    //});
    function applyGenerate(id) {
        $.post("/Home/GenerateContract", { "id": id },
            function (data) {
                $("#" + id).attr('href', data);
        });
    }

</script>
@if (ViewData["hetongjbxx"] != null)
{
    List<hetongjbxx> list = (List<hetongjbxx>)ViewData["hetongjbxx"];
    if (list != null && list.Count > 0)
    {
        <table width="100%">
            <tr>
                <th>合同编号</th>
                <th>甲方单位名称</th>
                <th>乙方单位名称</th>
                <th>代办人</th>
                <th>项目单位名称</th>
                <th>生成合同</th>
                <th>合同文件</th>
            </tr>
            @foreach (var item in list)
            {
                <tr>
                    <td>@item.hetongbh</td>
                    <td>@item.danweimc1</td>
                    <td>@item.danweimc2</td>
                    <td>@item.daibiaoren1</td>
                    <td>@item.xiangmudwmc</td>
                    @* jquery异步请求无法处理文件流，改为直接请求方式 *@
                    <td><a href="javascript:void(0)" onclick="applyGenerate(@item.id)">生成</a></td>
                    <td><a id="@item.id" href="/Home/GenerateContract/@item.id">点击下载</a></td>
                </tr>
            }
        </table>
    }
}
